package com.unknowpupil.design.memento;

/**
 * @Description: <p>
 *
 * </p>
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2020/4/28 17:03
 * @Classname: Client
 * @Version: 1.0
 */
public class Client {
    public static void main(String[] args) {
        CareTaker taker = new CareTaker();
        Emp emp = new Emp("小明",20,3900);
        System.out.println("第一次创建对象：\n"+"姓名:"+emp.getEname()+"年龄:"+emp.getAge()+"工资:"+emp.getSalary());
        //备份
        taker.setMemento(emp.memento());

        emp.setAge(38);
        emp.setSalary(4900);
        emp.setEname("小红");
        System.out.println("第二次创建对象：\n"+"姓名:"+emp.getEname()+"年龄:"+emp.getAge()+"工资:"+emp.getSalary());
        //回复到备忘录对象保持的状态
        emp.recovery(taker.getMemento());
        System.out.println("第三次次创建对象：\n"+"姓名:"+emp.getEname()+"年龄:"+emp.getAge()+"工资:"+emp.getSalary());

    }
}
